﻿<%@ Page Title="Най-четени" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeFile="MostReaded.aspx.cs" Inherits="MostReaded" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CenterContentPlaceHolder" runat="Server">
    <asp:ListView ItemPlaceholderID="itemPlaceHolder" ID="SearchArchiveListView" runat="server"
        DataSourceID="SearchArchiveDataSource">
        <ItemTemplate>
            <tr style="background-color: #DCDCDC; color: #000000;">
                <td>
                    <asp:HyperLink ID="SearchLink" NavigateUrl='<%# "/ViewPage.aspx?id=" + Eval("Key.ID") %>'
                       Text='<%# Eval("Key.Title") %>' runat="server" />
                </td>
                <td>
                    <%# ((DateTime)Eval("LastReaded")).ToString("dd.MM.yyyy-hh:mm") %>
                </td>
                <td>
                    <%# Eval("TimesReaded") %>
                </td>
            </tr>
        </ItemTemplate>
        <EmptyDataTemplate>
            <table id="Table1" runat="server" style="background-color: #FFFFFF; border-collapse: collapse;
                border-color: #999999; border-style: none; border-width: 1px;">
                <tr>
                    <td>
                        Няма намерени данни.
                    </td>
                </tr>
            </table>
        </EmptyDataTemplate>
        <LayoutTemplate>
            <table id="Table2" runat="server">
                <tr id="Tr1" runat="server">
                    <td id="Td1" runat="server">
                        <table id="itemPlaceholderContainer" runat="server" border="1" style="background-color: #FFFFFF;
                            border-collapse: collapse; border-color: #999999; border-style: none; border-width: 1px;
                            font-family: Verdana, Arial, Helvetica, sans-serif;">
                            <tr id="Tr2" runat="server" style="background-color: #DCDCDC; color: #000000;">
                                <th id="Th1" runat="server">
                                    Заглавие
                                </th>
                                <th id="Th2" runat="server">
                                    Последен преглед
                                </th>
                                <th id="Th3" runat="server">
                                    Общо
                                </th>
                            </tr>
                            <tr id="itemPlaceHolder" runat="server">
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr id="Tr3" runat="server">
                    <td id="Td2" runat="server" style="text-align: center; background-color: #CCCCCC;
                        font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000;">
                        <asp:DataPager ID="SearchArchiveDataPager" QueryStringField="page" PageSize="45"
                            PagedControlID="SearchArchiveListView" runat="server">
                            <Fields>
                                <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False"
                                    ShowPreviousPageButton="False" />
                                <asp:NumericPagerField />
                                <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False"
                                    ShowPreviousPageButton="False" />
                            </Fields>
                        </asp:DataPager>
                    </td>
                </tr>
            </table>
        </LayoutTemplate>
        <EditItemTemplate>
            <tr style="background-color: #008A8C; color: #FFFFFF;">
                <td>
                    <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
                </td>
                <td>
                    <asp:TextBox ID="SearchPhraseTextBox" runat="server" Text='<%# Bind("SearchPhrase") %>' />
                </td>
                <td>
                    <asp:TextBox ID="FirstSearchedOnTextBox" runat="server" Text='<%# Bind("FirstSearchedOn") %>' />
                </td>
                <td>
                    <asp:TextBox ID="LastSearchedOnTextBox" runat="server" Text='<%# Bind("LastSearchedOn") %>' />
                </td>
                <td>
                    <asp:TextBox ID="TimesSearchedTextBox" runat="server" Text='<%# Bind("TimesSearched") %>' />
                </td>
            </tr>
        </EditItemTemplate>
        <SelectedItemTemplate>
            <tr style="background-color: #008A8C; font-weight: bold; color: #FFFFFF;">
                <td>
                    <asp:Label ID="SearchPhraseLabel" runat="server" Text='<%# Eval("SearchPhrase") %>' />
                </td>
                <td>
                    <asp:Label ID="FirstSearchedOnLabel" runat="server" Text='<%# Eval("FirstSearchedOn") %>' />
                </td>
                <td>
                    <asp:Label ID="LastSearchedOnLabel" runat="server" Text='<%# Eval("LastSearchedOn") %>' />
                </td>
                <td>
                    <asp:Label ID="TimesSearchedLabel" runat="server" Text='<%# Eval("TimesSearched") %>' />
                </td>
            </tr>
        </SelectedItemTemplate>
    </asp:ListView>
    <asp:LinqDataSource ID="SearchArchiveDataSource" runat="server" ContextTypeName="FeedAgregator.FeedSignalDataContext"
        Select="new (Key,Count() as TimesReaded,Max(DateReaded) as LastReaded)" TableName="ReadHistories"
        GroupBy="FeedItem" OrderGroupsBy="Count() descending,Max(DateReaded) descending">
    </asp:LinqDataSource>
</asp:Content>
